﻿@using Janus.Cores.Tools
@using Janus.Mes.VO;
@model CalendarVO
@{
    Layout = null;
    string isView = ViewBag.IsView;
}

<style>
    .workDay {
        background-color: none;
    }

    .weekend {
        background-color: #CC6699;
    }

    .legalHoliday {
        background-color: #009966;
    }

    .daysOff {
        background-color: #FFFF00;
    }

    .calendarTable {
        border: 1px solid #b8d0d6;
        border-collapse: collapse; /* 边框合并属性  */
    }

        .calendarTable td {
            border: 1px solid #b8d0d6;
        }

    div.calendar_container_content td.clickable {
        cursor: pointer;
    }
</style>

<div id="calendar_container_edit">
    <form method="post" action="BaseData/Calendar/Edit?OpID=@ViewData["OperateID"]" class="pageForm required-validate"
          onsubmit="return validateCallback(this, dialogAjaxDone);">
        @Html.ValidationSummary(true)
        @Html.HiddenFor(model => model.YearContentJson)
        @Html.HiddenFor(model => model.WorkCCode)
        @Html.HiddenFor(model => model.Year)

        <div class="calendar_container_header pageHeader">
            <div class="searchBar">
                <table class="searchContent">
                    <tr>
                        <td>
                            年份：
                        </td>
                        <td>
                            <select id="sltYearEdit" class="WidthAsInputCombox" disabled="disabled">
                                <option value="@Model.Year">@Model.Year</option>
                            </select>
                        </td>
                        <td>
                            工作中心：
                        </td>
                        <td>
                            <select id="sltWorkCCodeEdit" class="required WidthAsInputCombox" disabled="disabled">
                                <option value="@Model.WorkCCode">@Model.WorkCName</option>
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="4">
                            @if (isView == "1")
                            {
                                <label><input class="calendarRadio" type="radio" name="redit" value="1" disabled="disabled"><span class="workDay">工作日</span></label>
                                <label><input class="calendarRadio" type="radio" name="redit" value="2" disabled="disabled"><span class="weekend">周末假日</span></label>
                                <label><input class="calendarRadio" type="radio" name="redit" value="3" disabled="disabled"><span class="legalHoliday">法定假日</span></label>
                                <label><input class="calendarRadio" type="radio" name="redit" value="4" disabled="disabled"><span class="daysOff">调休</span></label>
                            }
                            else
                            {
                                <label><input class="calendarRadio" type="radio" name="redit" value="1"><span class="workDay">工作日</span></label>
                                <label><input class="calendarRadio" type="radio" name="redit" value="2"><span class="weekend">周末假日</span></label>
                                <label><input class="calendarRadio" type="radio" name="redit" value="3"><span class="legalHoliday">法定假日</span></label>
                                <label><input class="calendarRadio" type="radio" name="redit" value="4"><span class="daysOff">调休</span></label>
                            }
                        </td>
                    </tr>
                </table>
            </div>
        </div>

        <div id="calendar_container_out_content_edit" layouth="95">

        </div>

        <div class="formBar">
            <ul>
                @if (isView != "1")
                {
                    <li>
                        <div class="buttonActive">
                            <div class="buttonContent">
                                <button type="submit" onclick="HandleSubmit()">
                                    保存
                                </button>
                            </div>
                        </div>
                    </li>
                }
                <li>
                    <div class="button">
                        <div class="buttonContent">
                            <button type="button" class="close">
                                返回列表
                            </button>
                        </div>
                    </div>
                </li>
            </ul>
        </div>
    </form>
</div>

<script type="text/javascript">
    $(function () {
        handleCalendarChange();
    });

    function handleCalendarChange() {
        var curDialog = $.pdialog.getCurrent();
        var year = $("#sltYearEdit", curDialog).val();
        var workCode = $("#sltWorkCCodeEdit", curDialog).val();
        var url = "/BaseData/Calendar/CldrContent?syear=" + year + "&sworkccode=" + workCode + "&isView=" + @isView;
        $("#calendar_container_out_content_edit", curDialog).load(url);
    }

    function HandleSubmit() {
        var curDialog = $.pdialog.getCurrent();
        var json = "["
        $("tr.clickableRow", curDialog).find("td[cldr_type_org]").each(function () {
            if($(this).attr("cldr_type_org") != $(this).attr("cldr_type_new"))
            {
                json += "{";
                json += "'CDate':'" + $(this).attr("cldr_date") + "',";
                json += "'Ctype':'" + $(this).attr("cldr_type_new") + "'";
                json += "},";
            }
        });
        json += "]";
        $("#YearContentJson", curDialog).val(json);
        $("#Year", curDialog).val($("#sltYearEdit", curDialog).val());
        $("#WorkCCode", curDialog).val($("#sltWorkCCodeEdit", curDialog).val());
    }

</script>